"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _forEach = _interopRequireDefault(require("./forEach"));
/**
 * 前序遍历查找节点，多个匹配时也只会找到第一个匹配的节点
 * @param treeNodes
 * @param callback
 * @param options
 * @returns
 */
const find = (treeNodes, callback, options) => {
  let result;
  (0, _forEach.default)(treeNodes, (treeNode, opts) => {
    if (callback(treeNode, opts)) {
      result = treeNode;
      return true;
    }
  }, {
    ...options,
    order: 'dlr'
  });
  return result;
};
var _default = exports.default = find;